/****************************
 *计算机中较为简单的排序算法
 ****************************/

int bubble_sort(int * data, int data_lenth)
{
	int i,j,temp;
	int exchange = 0;

	if (data == 0 || data_lenth <= 0)
	{
		return -1;
	}


	for (i = 0; i<data_lenth; i++)
	{
		for (j = 0; j < data_lenth-1-i; j++)
		{
			if (data[j] > data[j+1])
			{
				temp = data[j];
				data[j] = data[j+1];
				data[j+1] = temp;
				exchange = 1;
			}
		}
		if (exchange == 0)
		{
			break;
		}
	}

	


	return 0;	

}
